<template>
  <div
    class="warning-bar"
    :class="href && 'can-click'"
    @click="open"
    v-if="closed"
  >
    <el-icon class="title-icon">
      <warning-filled />
    </el-icon>
    <span class="title-span m-2">
      {{ title }}
    </span>
    <span class="close" @click="closed = false"> 取消 </span>
  </div>
</template>
<script setup>
import { WarningFilled } from "@element-plus/icons-vue";
import { ref } from "vue";

const closed = ref(true);

const prop = defineProps({
  title: {
    type: String,
    default: "",
  },
  href: {
    type: String,
    default: "",
  },
});

const open = () => {
  if (prop.href) {
    window.open(prop.href);
  }
};
</script>
<style lang="scss" scoped>
.warning-bar {
  background-color: #fff5ed;
  font-size: 14px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  border-radius: 2px;
  .title-icon {
    font-size: 18px;
    color: #ed6a0c;
  }
  margin-bottom: 12px;
  .title-span {
    line-height: 22px;
    color: #f67207;
    margin-left: 8px;
  }
}
.close {
  cursor: pointer;
  font-size: 12px;
  color: #0c2eed;
  // margin-left: 105px;
}

.can-click {
  cursor: pointer;
}
</style>
